package com.example.administrator.weixintext;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.weixintext.wechat.Session;
import com.example.administrator.weixintext.wechat.SessionAdapter;

import java.util.ArrayList;
import java.util.List;

public class ChatFragment extends Fragment {

    public List<Session> mSessions;

    public ChatFragment() {
        mSessions = new ArrayList<>();
        mSessions.add(new Session(R.drawable.default_useravatar , "1号"));
        mSessions.add(new Session(R.drawable.default_contactlabel , "2号"));
        mSessions.add(new Session(R.drawable.default_useravatar , "3号"));
        mSessions.add(new Session(R.drawable.default_servicebrand_contact, "4号"));
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        final RecyclerView rlvSession = (RecyclerView) getActivity().findViewById(R.id.rlv_wechat_sessions);
        rlvSession.setLayoutManager(new LinearLayoutManager(getContext()));

        SessionAdapter adapter = new SessionAdapter(mSessions);
        rlvSession.setAdapter(adapter);

        rlvSession.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        return inflater.inflate(R.layout.fragment_chat, container, false);
    }

}
